package com.sc.VenusQueryBeta.presenter.login;

import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.sc.VenusQueryBeta.contract.login.ForgotNextContract;
import com.sc.VenusQueryBeta.model.bean.login.ChangePwdBean;
import com.sc.VenusQueryBeta.model.login.ForgotNextModel;

import io.reactivex.functions.Consumer;

/**
 * Created by Administrator on 2018/11/12.
 */

public class ForgotNextPresenter extends ForgotNextContract.ForgotNextPresenter {
    @Override
    protected ForgotNextContract.IForgotNextModel getModel() {
        return ForgotNextModel.newInstance();
    }

    @Override
    public void onStart() {

    }

    public static ForgotNextPresenter newInstance(){
        return new ForgotNextPresenter();
    }

    /**
     * 修改密码
     * @param id
     * @param newPassword
     */
    @Override
    public void forgot(String id, String newPassword) {
        mRxManager.register(mIModel.forgotpwd(id,newPassword).subscribe(new Consumer<ChangePwdBean>() {
            @Override
            public void accept(ChangePwdBean changePwdBean) throws Exception {
                if (mIView != null)
                    mIView.showChangePwdSuccess(changePwdBean);

            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                LogUtils.e("accept");
                if (mIView != null)
                    //  mIView.showToast("Network error.33");
                    mIView.showNetworkError();
            }
        }));
    }
}
